<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../css/style.css">
    <script src="../plugins/echarts/echarts.js"></script>
    <!--element日期所需-->
    <script src="../js/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <link rel="stylesheet" href="../plugins/elementui/index.css">
</head>
<body class="hold-transition">


<div id="app">
    <div class="content-header">
        <h1>年龄统计</h1>
    </div>
    <div class="app-container">
        <div class="box">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div id="chart1" style="height:600px;"></div>
        </div>
    </div>
</div>
</body>

<script src="../js/axios-0.18.0.js"></script>
<script>        var vue = new Vue({
    el: "#date",
    data: {value: ''},
    created() {
        this.sendAndGet()
    }, methods: {
        sendAndGet() {
            var myChart = echarts.init(document.getElementById('chart1'));
            axios.get("/report/age.do").then((res) => {
                if (res.data.flag) {
                    myChart.setOption({
                        xAxis: {
                            type: 'category',
                            data: res.data.data.ages
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [{
                            data: res.data.data.count,
                            type: 'bar',
                            showBackground: true,
                            backgroundStyle: {
                                color: 'rgba(220, 220, 220, 0.8)'
                            }
                        }]
                    });
                } else {
                    this.$message.error("查询失败")
                }
            });
        }
    }
})    </script>

</html>